home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / gsdbloo.exe / DEMOU005.PAS < prev    next >
Pascal/Delphi Source File  |  1992-02-24  |  4KB  |  129 lines

  1. program DemoU005;
  2. {-----------------------------------------------------------------------------
  3.                              DBase Status Checker
  4.                                Useless Examples
  5.                                  Demo Program
  6.  
  7.        Copyright (c)  Richard F. Griffin
  8.  
  9.        10 February 1992
  10.  
  11.        102 Molded Stone Pl
  12.        Warner Robins, GA  31088
  13.  
  14.        -------------------------------------------------------------
  15.  
  16.        Demonstrates use of status checking for long duration operations
  17.  
  18.        Several functions in GS_dBase can take some time to complete
  19.        (e.g., IndexTo and Pack).  For this reason, a virtual method
  20.        StatusUpdate has been added to the GS_dBFld unit to allow the user
  21.        to gain access and track progress.  The StatusUpdate method in
  22.        GS_dBFld does nothing--it is there as the default if the user chooses
  23.        not to take advantage of the capability by adding his or her own
  24.        virtual StatusUpdate method.
  25.  
  26.        This sample program demonstrates the how this procedure may be
  27.        installed in a user's program.  Note a StatusUpdate method is
  28.        implemented through a child object of GS_dBFld.  All calls to
  29.        StatusUpdate anywhere in the object's heirarchy will come through
  30.        this 'hook'.
  31.  
  32.        Constants passed as arguments are contained in the GS_dBFld unit,
  33.        they are:
  34.  
  35.        StatusStart     = -1;   Passed to indicate a routine will be passing
  36.                                status update information.
  37.  
  38.        StatusStop      = 0;    Signals termination by a routine, cancelling
  39.                                status update processing.
  40.  
  41.        StatusIndexTo   = 1;    Token for identifying IndexTo as the routine
  42.                                passing status information.
  43.  
  44.        StatusPack      = 2;    Token for identifying Paack as the routine
  45.                                passing status information.
  46.  
  47.        The structure of a StatusUpdate call is:
  48.  
  49.        StatusUpdate(statword1, statword2, statword3);
  50.  
  51.        where the statword* values are type longint and will vary depending on
  52.        the contents of statword1.  For example:
  53.  
  54.        if     statword1 = StatusStart
  55.        then:  statword2 = the calling routine token (StatusIndexTo or
  56.                           StatusPack.
  57.               statword3 = the number of records to be processed.
  58.  
  59.        if     statword1 = StatusStop
  60.        then:  statword2 = 0
  61.               statword3 = 0
  62.  
  63.        if      statword1 = StatusIndexTo or StatusPack
  64.        then:   statword2 = current record number being processed
  65.                statword3 = 0
  66.  
  67. ------------------------------------------------------------------------------}
  68.  
  69. uses
  70.    CRT,
  71.    DOS,
  72.    GS_dBFld,
  73.    GS_dBase,
  74.    GS_GenF;
  75.  
  76. type
  77.    Talk_Obj  = object(GS_dBFld_Objt)
  78.       procedure   StatusUpdate(stat1,stat2,stat3 : longint); virtual;
  79.    end;
  80.  
  81. var
  82.    MyFile  : Talk_Obj;
  83.  
  84. procedure Talk_Obj.StatusUpdate(stat1,stat2,stat3 : longint);
  85. begin
  86.    case stat1 of
  87.       StatusStart   : begin
  88.                          GotoXY(2,1);
  89.                          case stat2 of
  90.                             StatusPack  : write('[ Pack Progress ]');
  91.                             StatusIndexTo : write('[ Index Progress ]');
  92.                          end;
  93.                          GotoXY(26,2);
  94.                          write('Total Records to Process = ',stat3);
  95.                       end;
  96.       StatusStop    : begin
  97.                          GoToXY(2,3);
  98.                          Writeln('Finished');
  99.                       end;
  100.       StatusPack,
  101.       StatusIndexTo : begin
  102.                          GoToXy(2,2);
  103.                          write('Record Number ',stat2,'  ');
  104.                       end;
  105.    end;
  106. end;
  107.  
  108. begin
  109.    ClrScr;
  110.  
  111.    writeln('Creating DemoU5.DBF');
  112.    MakeTestData('DemoU5', 100, false);
  113.    writeln('DemoU5.DBF Created');
  114.  
  115.    ClrScr;
  116.    MyFile.Init('DEMOU5');
  117.    MyFile.Open;
  118.    MyFile.IndexTo('DEMOU5','LASTNAME');
  119.    MyFile.Index('DEMOU5');
  120.    MyFile.GetRec(Top_Record);
  121.    while not MyFile.File_EOF do
  122.    begin
  123.       writeln(MyFile.FieldGet('LASTNAME'),'   ',
  124.               MyFile.FieldGet('FIRSTNAME'));
  125.       MyFile.GetRec(Next_Record);
  126.    end;
  127.    MyFile.Close;
  128. end.
  129.